home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / CPlus Files / ABTopic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-26  |  17.7 KB  |  853 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABTopic.c
  15.  
  16. NAME
  17.     ABTopic.c, part of the ABox project source code,
  18.     responsible for handling the AboutBox Topic class stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                ttempel@monmouth.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <ttempel@monmouth.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     9 June 94    -    ty    -    Initial Version Created
  36.     20-july-94    -    ty    -    initial version released
  37.     28-july-94    -    ty    -    1.0.6 -- removed cursor code to mix-in class
  38.                                 ABUCursor; removed cursor flipping from Load
  39.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  40.                             release and the associated Universal Headers from Apple:
  41.                             most methods that returned references now have "Ref" at
  42.                             the end of their methods names to prevent possible collisions
  43.                             with datatypes and classes of the same name (older versions
  44.                             of the compiler didn't have a problem with this).
  45.     25-oct-95    -    ty    -    changes for "const" usage under CW7; simplification of Boolean
  46.                             query methods
  47. */
  48.  
  49. /*===========================================================================*/
  50.  
  51. /*======= Segmentation directives ========*/
  52.  
  53. #ifdef USE_MANUAL_SEGMENTATION
  54. #pragma segment ty
  55. #endif
  56.  
  57. /*============ Header files ==============*/
  58.     
  59. #include     "ABTopic.h"
  60. #include    "ABoxDefs.h"
  61. #include    "ABSlide.h"
  62.  
  63.  
  64. #include    "ABPict.h"
  65. #include    "ABText.h"
  66. #include    "ABStr.h"
  67. #include    "ABSound.h"
  68.  
  69. #include    "ABUCursor.h"
  70.  
  71. /*=============== Globals ================*/
  72.  
  73. /*================ CODE ==================*/
  74.  
  75.  
  76. /*=============================== ABTopic::ABTopic ================================*/
  77. ABTopic::ABTopic(void)
  78. {
  79.     this->InitializeTopic();
  80. } // end ABTopic
  81.  
  82.  
  83.  
  84. /*=============================== ABTopic::ABTopic ================================*/
  85. ABTopic::ABTopic(const FSSpec& inTopicFSSpec)
  86. {
  87.     this->InitializeTopic();
  88.     (void)this->CheckAndCopyFSSpec(inTopicFSSpec);
  89. } // end ABTopic
  90.  
  91.  
  92.  
  93. /*=============================== ABTopic::InitializeTopic ================================*/
  94. void
  95. ABTopic::InitializeTopic(void)
  96. {
  97.     this->SlidesRef() = new ABLinkedList;
  98.     this->FSSpecPointerRef() = NULL;
  99.     this->NameRef() = (StringPtr)::NewPtrClear (kABTopicNameSize);
  100.     this->FileRefNumRef() = kABBadTopicFileRefNum;
  101.     this->TopicType() = ETopicType_Topic;
  102. } // end InitializeTopic
  103.  
  104.  
  105.  
  106. /*=============================== ABTopic::~ABTopic ================================*/
  107. ABTopic::~ABTopic(void)
  108. {
  109.     (void)this->CloseTopicFile();
  110.  
  111.     if (this->HasFSSpecPointer())
  112.     {
  113.         ::DisposPtr ((Ptr)this->FSSpecPointerRef());
  114.         this->FSSpecPointerRef() = NULL;
  115.     }
  116.     
  117.     if (this->HasName())
  118.     {
  119.         ::DisposPtr ((Ptr)this->NameRef());
  120.         this->NameRef() = NULL;
  121.     }
  122.     
  123.     this->ResetSlideInfo();
  124.     
  125. } // end ~ABTopic
  126.  
  127.  
  128.  
  129. /*=============================== ABTopic::ResetSlideInfo ================================*/
  130. void
  131. ABTopic::ResetSlideInfo(void)
  132. {
  133.     if (this->HasSlides())
  134.     {
  135.         delete this->SlidesRef();
  136.         this->SlidesRef() = NULL;
  137.     }
  138.     
  139. } // end ResetSlideInfo
  140.  
  141.  
  142.  
  143. /*=============================== ABTopic::ResetFileInfo ================================*/
  144. void
  145. ABTopic::ResetFileInfo(void)
  146. {
  147.     this->ResetFSSpecPointer();
  148.     this->ResetFileRefNum();
  149. } // end ResetFileInfo
  150.  
  151.  
  152.  
  153.  
  154. /*=============================== ABTopic::ResetFSSpecPointer ================================*/
  155. void
  156. ABTopic::ResetFSSpecPointer(void)
  157. {
  158.     if (this->HasFSSpecPointer())
  159.     {
  160.         ::DisposPtr ((Ptr)this->FSSpecPointerRef());
  161.         this->FSSpecPointerRef() = NULL;
  162.     }
  163.     
  164. } // end ResetFSSpecPointer
  165.  
  166.  
  167.  
  168. /*=============================== ABTopic::ResetFileRefNum ================================*/
  169. void
  170. ABTopic::ResetFileRefNum(void)
  171. {
  172.     this->FileRefNumRef() = kABBadTopicFileRefNum;
  173.     
  174. } // end ResetFileRefNum
  175.  
  176.  
  177.     
  178.  
  179.  
  180. /*=============================== ABTopic::UseTopicResFile ================================*/
  181. short
  182. ABTopic::UseTopicResFile(void) const
  183. {
  184.     short oldResFile = ::CurResFile();
  185.     
  186.     if (this->HasFileRefNum())
  187.         ::UseResFile(this->GetFileRefNum());
  188.     
  189.     return oldResFile;
  190. } // end UseTopicResFile
  191.  
  192.  
  193.  
  194. /*=============================== ABTopic::ResizeAndDraw ================================*/
  195. OSErr
  196. ABTopic::ResizeAndDraw(Rect& inItemRect, WindowPtr inWindow)
  197. {
  198.     OSErr anError = noErr;
  199.     
  200.     anError = this->Resize(&inItemRect);
  201.     if (anError == noErr)
  202.         anError = this->EraseFrame(inItemRect);
  203.     if (anError == noErr)
  204.         anError = this->Draw(inWindow);
  205.     
  206.     return anError;
  207. } // end ResizeAndDraw
  208.  
  209.  
  210. /*=============================== ABTopic::GetProperty ================================*/
  211. OSErr    ABTopic::GetProperty(ABProperty prop, 
  212.                                 void *ptr, 
  213.                                 long *ptrSize)
  214. {
  215.     OSErr    error = noErr;
  216.     long    pSize;
  217.     
  218.     //    begin here...
  219.     
  220.     if (!ptr)
  221.         return kABPropertyNullStorage;
  222.     
  223.     switch (prop)
  224.     {
  225.         case    kABTopicIndex:
  226.                     *((ABIndex *)ptr) = this->Ordinal();
  227.                     pSize = kABTopicIndexSize;
  228.                     break;
  229.         case    kABTopicNumberOfSlides:
  230.                     if (this->HasSlides())
  231.                         *((ABListCount *)ptr) = this->SlidesRef()->Count();
  232.                     else
  233.                         *((ABListCount *)ptr) = 0;
  234.                     pSize = kABTopicNumberOfSlidesSize;
  235.                     break;
  236.         case    kABTopicFSSpec:
  237.                     if (this->HasFSSpecPointer())
  238.                         *((FSSpecPtr)ptr) = *(this->FSSpecPointerRef());
  239.                     pSize = kABTopicFSSpecSize;
  240.                     break;
  241.         case    kABTopicName:
  242.                     if (this->HasName())
  243.                         ::BlockMove (this->NameRef(), (Ptr)ptr, *(this->NameRef())+1);
  244.                     pSize = kABTopicNameSize;
  245.                     break;
  246.         case    kABTopicDepth:
  247.                     *((long *)ptr) = this->Depth();
  248.                     pSize = kABTopicDepthSize;
  249.                     break;
  250.         case    kABTopicType:
  251.                     *((ETopicType *)ptr) = this->TopicType();
  252.                     pSize = kABTopicTypeSize;
  253.                     break;
  254.         default:
  255.                     error = kABTopicSuperProperties::GetProperty(prop, ptr, ptrSize);
  256.                     break;
  257.     } // end switch block
  258.     
  259.     if (ptrSize && !error)
  260.         *ptrSize = pSize;
  261.     return error;
  262.     
  263. } // end GetProperty
  264.  
  265.  
  266.  
  267. /*=============================== ABTopic::SetProperty ================================*/
  268. OSErr    ABTopic::SetProperty(ABProperty prop, 
  269.                                 void *ptr, 
  270.                                 long ptrSize)
  271. {
  272.     OSErr    error = noErr;
  273.     
  274.     //    begin here...
  275.     
  276.     if (!ptr)
  277.         return kABPropertyNullStorage;
  278.     
  279.     switch (prop)
  280.     {
  281.         case    kABTopicNumberOfSlides:
  282.         case    kABTopicFSSpec:
  283.         case    kABTopicName:
  284.         case    kABTopicDepth:
  285.         case    kABTopicType:
  286.                     error = kABPropertyReadOnly;
  287.                     break;
  288.         default:
  289.                     error = kABTopicSuperProperties::SetProperty(prop, ptr, ptrSize);
  290.                     break;
  291.     } // end switch block
  292.     
  293.     return error;
  294.     
  295. } // end SetProperty
  296.  
  297.  
  298.  
  299.  
  300.  
  301. /*=============================== ABTopic::Draw ================================*/
  302. OSErr    ABTopic::Draw(WindowPtr window)
  303. {
  304.     OSErr    error = noErr;
  305.     
  306.     ABSlide        *slide = NULL;
  307.     short        curResFile = ::CurResFile();
  308.     
  309.     //    begin here...
  310.     //
  311.     short        oldResFile = this->UseTopicResFile();
  312.  
  313.     slide = this->CurrentSlide();
  314.     if (slide)
  315.         error = slide->Draw(window);
  316.     
  317.     ::UseResFile (oldResFile);
  318.     
  319.     return error;
  320.     
  321. } // end Draw
  322.  
  323.  
  324.  
  325. /*=============================== ABTopic::Update ================================*/
  326. OSErr    ABTopic::Update(WindowPtr window)
  327. {
  328.     OSErr    error = noErr;
  329.     
  330.     ABSlide        *slide = NULL;
  331.     
  332.     //    begin here...
  333.     //
  334.     short        oldResFile = this->UseTopicResFile();
  335.         
  336.     slide = this->CurrentSlide();
  337.     if (slide)
  338.         error = slide->Update(window);
  339.         
  340.     ::UseResFile (oldResFile);
  341.     
  342.     return error;
  343.     
  344. } // end Update
  345.  
  346.  
  347.  
  348.  
  349. /*=============================== ABTopic::Event ================================*/
  350. Boolean    ABTopic::Event(EventRecord *eventRec)
  351. {
  352.     Boolean    handled = false;
  353.     
  354.     ABSlide        *slide = NULL;
  355.     
  356.     //    begin here...
  357.     //
  358.     short        oldResFile = this->UseTopicResFile();
  359.         
  360.     slide = this->CurrentSlide();
  361.     if (slide)
  362.         handled = slide->Event(eventRec);
  363.         
  364.     ::UseResFile(oldResFile);
  365.     
  366.     return handled;
  367.  
  368. } // end Event
  369.  
  370.  
  371.  
  372. /*=============================== ABTopic::Stop ================================*/
  373. OSErr    ABTopic::Stop(void)
  374. {
  375.     OSErr        error = noErr;
  376.     ABSlide        *slide = NULL;
  377.     
  378.     //    begin here...
  379.     //
  380.     short        oldResFile = this->UseTopicResFile();
  381.         
  382.     slide = this->CurrentSlide();
  383.     if (slide)
  384.         error = slide->Stop();
  385.     
  386.     ::UseResFile (oldResFile);
  387.     
  388.     return error;
  389.     
  390. } // end Stop
  391.  
  392.  
  393.  
  394.  
  395. /*=============================== ABTopic::NextSlide ================================*/
  396. OSErr    ABTopic::NextSlide(void)
  397. {
  398.     OSErr        error = noErr;
  399.     ABSlide        *slide;
  400.     
  401.     error = this->Stop();
  402.     if (this->HasSlides())
  403.     {
  404.         slide = (ABSlide *)(this->SlidesRef()->NextLink());
  405.     } // end if (slides)
  406.     
  407.     return error;
  408. } // end NextSlide
  409.  
  410.     
  411.         
  412.  
  413. /*=============================== ABTopic::PreviousSlide ================================*/
  414. OSErr    ABTopic::PreviousSlide(void)
  415. {
  416.     OSErr        error = noErr;
  417.     ABSlide        *slide;
  418.     
  419.     error = this->Stop();
  420.     if (this->HasSlides())
  421.     {
  422.         slide = (ABSlide *)(this->SlidesRef()->PreviousLink());
  423.     } // end if (slides)
  424.     
  425.     return error;
  426. } // end PreviousSlide
  427.  
  428.  
  429.  
  430. /*=============================== ABTopic::CurrentSlide ================================*/
  431. ABSlide    *ABTopic::CurrentSlide(void)
  432. {    
  433.     if (this->HasSlides())
  434.     {
  435.         return (ABSlide *)(this->SlidesRef()->GetCurrentLink());
  436.     } else {
  437.         return NULL;
  438.     } // end if (slides)
  439.     
  440. } // end CurrentSlide
  441.  
  442.  
  443.  
  444. /*=============================== ABTopic::GotoSlide ================================*/
  445. OSErr    ABTopic::GotoSlide(long number)
  446. {
  447.     OSErr        error = noErr;
  448.     ABSlide        *slide;
  449.     
  450.     error = this->Stop();
  451.     if (this->HasSlides())
  452.     {
  453.         slide = (ABSlide *)(this->SlidesRef()->GotoLink(number));
  454.         if (!slide)
  455.             error = paramErr;
  456.     } // end if (slides)
  457.     
  458.     return error;
  459. } // end GotoSlide
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. /*=============================== ABTopic::Resize ===============================*/
  467. //
  468. //    this function will rearrange and resize the picture and the
  469. //    text fields that appear on a slide.
  470. //
  471. //    This method will cause the current slide for the
  472. //    topic to resize by invoking that item's resize method.
  473. //
  474. //    is called by:
  475. //
  476. OSErr    ABTopic::Resize (Rect const *field)
  477. {
  478.     OSErr    error = noErr;
  479.     ABSlide    *currentSlide = NULL;
  480.     
  481.     //    begin here...
  482.     
  483.     if (field == NULL)
  484.         return paramErr;
  485.     
  486.     Rect box = *field;
  487.     error = this->SetProperty(kABObjectRect, &box, kABObjectRectSize);
  488.     if (error != noErr)
  489.         return error;
  490.         
  491.     if (this->HasSlides())
  492.         currentSlide = (ABSlide *) this->SlidesRef()->GetCurrentLink();
  493.     
  494.     if (currentSlide)
  495.         error = currentSlide->Resize(field);
  496.  
  497.     return error;
  498. } // end of Resize
  499.  
  500.  
  501.  
  502.  
  503. /*=============================== ABTopic::CheckAndCopyFSSpec ===============================*/
  504. //
  505. //    This function will copy and/or create an FSSpecPtr
  506. //    from the given parameter.
  507. //
  508. //
  509. OSErr    ABTopic::CheckAndCopyFSSpec (const FSSpec& file)
  510. {
  511.     OSErr            error = noErr;
  512.     
  513.     //    begin here...
  514.  
  515.     //    the caller has specified a topic file to use,
  516.     //    so we'll replace whatever one we might have internally
  517.     //    with this one.
  518.     
  519.     if (this->DoesntHaveFSSpecPointer())
  520.     {
  521.         //    oops! we need to create some storage first...
  522.         this->FSSpecPointerRef() = (FSSpecPtr)::NewPtrClear(kABTopicFSSpecSize);
  523.         error = ::MemError();
  524.         if (error || this->DoesntHaveFSSpecPointer())
  525.         {
  526.             //    yikes! storage failed! mayday!mayday! danger will robinson...
  527.             if (!error)
  528.                 error = memFullErr;
  529.             return error;
  530.         } // end if block
  531.     } // end if block
  532.     
  533.     //    use the one passed as the argument, but save it
  534.     //    into the object's field
  535.     ::BlockMove ((Ptr)&file, (Ptr)this->FSSpecPointerRef(), kABTopicFSSpecSize);
  536.     
  537.     return error;
  538. } // end CheckAndCopyFSSpec()
  539.  
  540.  
  541.  
  542.  
  543.  
  544. /*=============================== ABTopic::OpenTopic ================================*/
  545. OSErr    ABTopic::OpenTopic(void)
  546. {
  547.     OSErr        error = noErr;
  548.  
  549.     //    begin here...
  550.     
  551.     ABUCursor::WatchCursor();
  552.     if (this->HasFSSpecPointer())
  553.     {
  554.         this->FileRefNumRef() = ::FSpOpenResFile (this->FSSpecPointerRef(), fsRdPerm);
  555.         error = ::ResError();
  556.     } // end if block
  557.     
  558.     if (!error && this->HasFileRefNum())
  559.     {
  560.         (void)this->UseTopicResFile();
  561.         error = this->GotoSlide(1);
  562.     } // end if block
  563.     
  564.     ABUCursor::ArrowCursor();
  565.     return error;
  566. } // end OpenTopic
  567.  
  568.  
  569.  
  570.  
  571. /*=============================== ABTopic::CloseTopicFile ================================*/
  572. OSErr    ABTopic::CloseTopicFile(OSErr inError)
  573. {
  574.     OSErr        error = noErr;
  575.  
  576.     //    begin here...
  577.     error = this->CloseTopicFile();
  578.  
  579.     if (inError != noErr)
  580.         this->ResetFileInfo();
  581.         
  582.     return error;
  583. } // end CloseTopicFile
  584.  
  585.  
  586.  
  587. /*=============================== ABTopic::CloseTopicFile ================================*/
  588. OSErr    ABTopic::CloseTopicFile(void)
  589. {
  590.     OSErr        error = noErr;
  591.  
  592.     //    begin here...
  593.     if (this->HasFSSpecPointer() && this->HasFileRefNum())
  594.     {
  595.         ::CloseResFile(this->FileRefNumRef());
  596.         error = ::ResError();
  597.         this->ResetFileRefNum();
  598.     } // end if block
  599.  
  600.     return error;
  601. } // end CloseTopicFile
  602.  
  603.  
  604.  
  605.  
  606. /*=============================== ABTopic::CloseTopic ================================*/
  607. OSErr    ABTopic::CloseTopic(void)
  608. {
  609.     OSErr        error = noErr;
  610.  
  611.     //    begin here...
  612.     
  613.     ABUCursor::WatchCursor();
  614.     error = this->Stop();
  615.  
  616.     if (error == noErr)
  617.         error = this->CloseTopicFile();
  618.  
  619.     ABUCursor::ArrowCursor();
  620.     return error;
  621. } // end CloseTopic
  622.  
  623.  
  624.  
  625.  
  626. /*=============================== ABTopic::Load ===============================*/
  627. //
  628. //
  629. OSErr    ABTopic::Load (short inFileRefToUse)
  630. {
  631.     OSErr            error = noErr;
  632.  
  633.     this->FileRefNumRef() = inFileRefToUse;
  634.     
  635.     error = this->Load();
  636.     return error;
  637.  
  638. } // end of Load
  639.  
  640.  
  641.  
  642.  
  643. /*=============================== ABTopic::Load ===============================*/
  644. //
  645. //
  646. OSErr    ABTopic::Load (void)
  647. {
  648.     OSErr            error = noErr;
  649.  
  650.     short            count = 0;
  651.     short            id = 0;
  652.     Handle            rHandle = NULL;
  653.     Ptr                rPtr = NULL;
  654.     ABSlide            *slide = NULL;
  655.     const short        size = sizeof(short int);
  656.     const short        resourceIndex = 1;
  657.     Boolean            slideCount = false;
  658.     
  659.     //    begin here...
  660.  
  661.     //    if not given an FSSpecPtr, this topic will attempt to grab from the current
  662.     //    resource file.
  663.     if (this->DoesntHaveFSSpecPointer() && !this->HasFileRefNum())
  664.     {
  665.         //    we don't have a file to look at, or an open resource
  666.         //    file that we should look at, so return
  667.         this->ResetFileInfo();
  668.         error = resNotFound;
  669.     } else {
  670.         slideCount = this->DoCheckSlides();
  671.         if (slideCount < 1)
  672.         {
  673.             //    there wasn't anything of interest...
  674.             //
  675.             error = resNotFound;
  676.         } // end if (error)
  677.     
  678.     } // end if block
  679.     
  680.     if (error == noErr)
  681.         error = this->DoLoad();
  682.     
  683.     this->CloseTopicFile(error);
  684.  
  685.     return error;
  686.  
  687. } // end of Load
  688.  
  689.  
  690.  
  691. /*=============================== ABTopic::DoCheckSlides ===============================*/
  692. //
  693. //    This function checks a file for the presense of a topic/slide definition
  694. //    resource and will an error type (OSErr)
  695. //
  696. //
  697. //    is called by:
  698. //
  699. short    ABTopic::DoCheckSlides (void)
  700. {
  701.     OSErr            error = noErr;
  702.     short            tempRefNum, oldResFile;
  703.     short            count = 0;
  704.     
  705.     //    begin here...
  706.  
  707.     oldResFile = ::CurResFile();
  708.     if (this->HasFSSpecPointer()) 
  709.     {
  710.         //    check the given file...
  711.         
  712.         tempRefNum = ::FSpOpenResFile (this->FSSpecPointerRef(), fsRdPerm);
  713.         error = ::ResError();
  714.         if (error)
  715.         {
  716.             ::UseResFile (oldResFile);
  717.             return count;
  718.         } // end if block
  719.         
  720.     } else if (this->HasFileRefNum()) {
  721.         //    check the preset, pre-opened resource file
  722.         tempRefNum = this->FileRefNumRef();
  723.     } else {
  724.         //    nothing to check, so leave...
  725.         return count = 0;
  726.     } // end if block
  727.     
  728.     ::UseResFile(tempRefNum);
  729.     count = ::Count1Resources (kABTopicSlideResource);
  730.     error = ::ResError();
  731.     
  732.     if (!error && count < 1)
  733.         error = resNotFound;
  734.         
  735.     if (this->HasFSSpecPointer()) 
  736.     {
  737.         ::CloseResFile(tempRefNum);
  738.     } // end if block
  739.                 
  740.     ::UseResFile(oldResFile);
  741.     return count;
  742.     
  743. }    //    end of function DoCheckSlides
  744.  
  745.  
  746. /*=============================== ABTopic::DoLoad ===============================*/
  747. //
  748. //
  749. OSErr    ABTopic::DoLoad (void)
  750. {
  751.     OSErr            error = noErr;
  752.  
  753.     short            count = 0;
  754.     short            id = 0;
  755.     Handle            rHandle = NULL;
  756.     Ptr                rPtr = NULL;
  757.     ABSlide            *slide = NULL;
  758.     short            slideNumber;
  759.     const short        size = sizeof(short int);
  760.     const short        resourceIndex = 1;
  761.     long            index;
  762.     short            oldRefNum;
  763.     Boolean            slideCount = false;
  764.     
  765.     //    begin here...
  766.  
  767.     //    if not given an FSSpecPtr, this topic will attempt to grab from the current
  768.     //    resource file.
  769.     if (this->DoesntHaveFSSpecPointer() && !this->HasFileRefNum())
  770.     {
  771.         //    we don't have a file to look at, or an open resource
  772.         //    file that we should look at, so return
  773.         this->ResetFileRefNum();
  774.         return resNotFound;
  775.     } // end if block
  776.         
  777.     //    we did find a slide resource, so now get it and
  778.     //    process it.
  779.     oldRefNum = ::CurResFile();
  780.     if (this->HasFSSpecPointer()) 
  781.     {
  782.         //    the caller specified a file to use, so save the
  783.         //    old one and open the new one.
  784.         this->FileRefNumRef() = ::FSpOpenResFile (this->FSSpecPointerRef(), fsRdPerm);
  785.         error = ::ResError();
  786.         if (error) 
  787.         {
  788.             this->ResetFileRefNum();
  789.             ::UseResFile (oldRefNum);
  790.             return error;
  791.         } // end if else block
  792.     } // end if block
  793.     
  794.     //    set the resource file!
  795.     (void)this->UseTopicResFile();
  796.     
  797.     //    get the resource.
  798.     rHandle = ::Get1IndResource (kABTopicSlideResource, resourceIndex);
  799.     error = ::ResError();
  800.     
  801.     if (rHandle && !error && this->HasSlides()) 
  802.     {
  803.         //    we got everything we needed without a problem, so
  804.         //    load the resource into a data structure.
  805.         
  806.         ::HLock (rHandle);
  807.         rPtr = *rHandle;
  808.  
  809.         //    we have the resource, so now load it into a data structure
  810.         //
  811.         //    find out how large the list is:
  812.         ::BlockMove (rPtr, (Ptr)&count, size);
  813.         rPtr += size;
  814.             
  815.         for (index = 1; (index <= count) && rPtr; ++index) 
  816.         {
  817.             //    grab the next item from the resource
  818.             ::BlockMove (rPtr, (Ptr)&(slideNumber), size);
  819.             rPtr += size;
  820.             
  821.             //    create a new slide...
  822.             slide = new ABSlide;
  823.             if (slide)
  824.             {
  825.                 error = slide->SetProperty(kABSlideNumber, &slideNumber, kABSlideNumberSize);
  826.                 this->SlidesRef()->Append(slide);
  827.             } // end if (slide)
  828.             
  829.         }    //    end for(index) loop
  830.         
  831.         ::HUnlock (rHandle);
  832.  
  833.     } // end if block
  834.     
  835.     //    clean up time!
  836.     //
  837.     if (rHandle)
  838.         ::ReleaseResource(rHandle);
  839.     
  840.     ::UseResFile (oldRefNum);
  841.     
  842.     return error;
  843.     
  844. }    //    end of function DoLoad
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851. //    end of file
  852.  
  853.